<!-- 顶部导航栏 -->
<template>
  <wd-navbar
    style="z-index: 999; width: 100%"
    :left-text="leftTitle"
    left-arrow
    :right-text="rightTitle"
    :placeholder="true"
    :fixed="true"
    @click-left="handleClickLeft"
    @click-right="handleClickRight"
  />
</template>

<script lang="ts" setup>
import { useToast } from "wot-design-uni";

const props = defineProps({
  leftTitle: String,
  rightTitle: String,
  inToHome: Boolean,
  ToBePaid: Function,
});
const { show: showToast } = useToast();
function handleClickRight() {
  showToast("按钮");
}
function handleClickLeft() {
  showToast("返回");
  if (props.inToHome) {
    if (props.ToBePaid) {
      props.ToBePaid();
      uni.switchTab({ url: "/" });
    } else {
      uni.switchTab({ url: "/" });
    }
  } else {
    uni.navigateBack({ delta: 1 });
  }
}
</script>

<style lang="scss" scoped></style>
